import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    redirect: '/login',  // 设置根路径重定向到 /home
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue')
  },
  {
    path: '/home',
    component: () => import('../views/Home.vue'),
    children: [
      {
        path: '',  // 这个空路径代表默认子路由
        redirect: '/data',  // 默认重定向到 /data
      },
      {
        path: '/blog',
        component: () => import('../views/Blog.vue')
      },
      {
        path: '/ticket',
        component: () => import('../views/Ticket.vue')
      },
      {
        path: '/user',
        component: () => import('../views/User.vue')
      },
      {
        path: '/order',
        component: () => import('../views/Order.vue')
      },
      {
        path: '/scenic',
        component: () => import('../views/Scenic.vue')
      },
      {
        path: '/data',
        component: () => import('../views/showData.vue')
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
